package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilWatering;
import com.mc.fil.service.IFilWateringService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 浇水情况 浇水情况Controller
 *
 * @author mc
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/fil/watering")
public class FilWateringController extends BaseController
{
    @Autowired
    private IFilWateringService filWateringService;

    /**
     * 查询浇水情况 浇水情况列表
     */
    @PreAuthorize("@ss.hasPermi('fil:watering:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilWatering filWatering)
    {
        startPage();
        List<FilWatering> list = filWateringService.selectFilWateringList(filWatering);
        return getDataTable(list);
    }

    /**
     * 导出浇水情况 浇水情况列表
     */
    @PreAuthorize("@ss.hasPermi('fil:watering:export')")
    @Log(title = "浇水情况 浇水情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilWatering filWatering)
    {
        List<FilWatering> list = filWateringService.selectFilWateringList(filWatering);
        ExcelUtil<FilWatering> util = new ExcelUtil<FilWatering>(FilWatering.class);
        return util.exportExcel(list, "watering");
    }

    /**
     * 获取浇水情况 浇水情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:watering:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filWateringService.selectFilWateringById(id));
    }

    /**
     * 新增浇水情况 浇水情况
     */
    @PreAuthorize("@ss.hasPermi('fil:watering:add')")
    @Log(title = "浇水情况 浇水情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilWatering filWatering)
    {
        return toAjax(filWateringService.insertFilWatering(filWatering));
    }

}